This notebook shows that the variance of a random process which is the moving window integration of an uncorrelated Gaussian process scales with the number of points both for overlapping (correlated) and non-overlapping (uncorrelated) windows.
$\cdot$
In [1]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
In [2]:
svar = []
for t_step in (1, 3, 5, 10, 20, 30):
t_window = 30
decimation = 20
nwindow = int(t_window / t_step * decimation)
tot_steps = 100*1000
tot_points = tot_steps * decimation
s = np.random.randn(tot_points)
x = np.array([s[i:i+nwindow].mean() for i in range(0, tot_points, decimation)])
svar.append(x.var()*nwindow)
ρ_emp = (x[::2]*x[1::2]).mean()*nwindow
print('t_step = %2d; ρ(exact) = %4.2f; ρ(empiric) = %5.2f; Var{X}⋅nwindow = %.2f' %
(t_step, 1 - t_step/t_window, ρ_emp, x.var()*nwindow))
NOTE:
x
contains correlated samples. Its variance, however, scales linearly with the number of points in the averaging windown_avg
, similarly to uncorrelated variables.
In [ ]: